<!-- Pagination template -->
<ng-template #paginationTpl>
  <div class="pagination" *ngIf="source!.total > 1">
    <button class="btn-outline" [disabled]="currentPageIdx === 1" (click)="source!.prevPage()">
      <svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-5 h-5" viewBox="0 0 20 20" fill="currentColor">
        <path fill-rule="evenodd"
          d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"
          clip-rule="evenodd" />
      </svg>
      Previous
    </button>
    <span class="flex flex-row items-center gap-1">
      <button class="page" *ngFor="let page of pageNumbers" [class.active-page]="page === currentPageIdx"
        (click)="source!.openPage(page)">{{ page }}</button>
    </span>
    <button class="btn-outline" [disabled]="currentPageIdx+1 > source!.total" (click)="source!.nextPage()">
      Next
      <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" viewBox="0 0 20 20" fill="currentColor">
        <path fill-rule="evenodd"
          d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
          clip-rule="evenodd" />
      </svg>
    </button>
  </div>
</ng-template>
<!-- End Pagination Template -->

<ng-container *ngIf="!!content && !!source">
  <ng-container *ngTemplateOutlet="paginationTpl"></ng-container>
  <ng-container *ngTemplateOutlet="content!.templateRef">
  </ng-container>
  <ng-container *ngTemplateOutlet="paginationTpl"></ng-container>
</ng-container>
